﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.OleDb;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

namespace skvote
{
    public partial class admin_title_add : System.Web.UI.Page
    {
        private OleDbConnection connection = new conn().CreateConnection();
        protected void Page_Load(object sender, EventArgs e)
        {
            function.check();
        }

        protected void submit_Click(object sender, EventArgs e)
        {
            try
            {
                string sid = Request["sid"].Trim();
                string title = Request["title"].Trim();
                string ms = Request["ms"].Trim();
                string listtype = Request["listType"].Trim();
                string listrows = Request["listRows"].Trim();
                OleDbCommand qry = new OleDbCommand("select * from xh_title where title like \"%" + title.Trim() + "%\"",connection);
                OleDbDataReader dr = qry.ExecuteReader(CommandBehavior.CloseConnection);
                if (dr.HasRows)
                {
                    dr.Close();
                    function.showErr("已经存在此投票问题",Response,Request);
                }
                OleDbCommand cmd = new OleDbCommand("insert into xh_title(sid,title,ms,listtype,listrows) values(" + sid + ",\"" + title + "\"," + ms + "," + listtype + "," + listrows + ")", connection);
                cmd.ExecuteNonQuery();
                cmd.Dispose();
                function.successMsg("添加问题成功");
            }
            finally
            {
                connection.Close();
            }
        }
    }
}
